﻿using System.Collections.Generic;

namespace Resolve.FlagInfo
{
    /// <summary>
    /// 文件里面的代码标记
    /// </summary>
    public class FlagCodeInFile
    {
        /// <summary>
        /// 类名称
        /// </summary>
        public string ClassName;

        /// <summary>
        /// 文件路径或者字符串内容
        /// </summary>
        public readonly string Source;


        /// <summary>
        /// 编码标志
        /// </summary>
        public EncodingStyle EncodingStyle;

        /// <summary>
        /// 标志数组
        /// </summary>
        public List<FlagCode> LsCode
        {
            private set;
            get;
        }

        /// <summary>
        /// 编译类型
        /// </summary>
        public object CompileObject
        {
            set;
            get;
        }

        public FlagCodeInFile()
        {
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="sourceFlag">查找源标志，0则Source表示文件路径；1则Source表示字符串内容</param>
        /// <param name="source"></param>
        /// <param name="className"></param>
        public FlagCodeInFile(int sourceFlag, string source, string className)
        {
            Source = source;
            ClassName = className;
            LsCode = new List<FlagCode>();
            if (sourceFlag == 0)
            {
                ClassName = ResolveConfig.GenerateClassNameByFilePath(source);
            }
        }

        /// <summary>
        /// 添加标志位置
        /// </summary>
        /// <param name="flagCode"></param>
        public void AddCode(FlagCode flagCode)
        {
            LsCode.Add(flagCode);
        }
    }
}
